package com.leetcode.Offer;

public class JZ24 {
    public ListNode reverseList(ListNode head) {

        //三指针法:前中后三个指针，中间指针指向后面的指针，然后向后推移
        ListNode q = head;
        ListNode b=null;
        ListNode a=null;
        while (q != null) {
            a=q.next;
            q.next=b;
            b=q;
            q=a;
        }
        return b;
    }
}
